﻿package org.cubeland.game.core.drawing
{
	import org.cubeland.game.core.drawing.yuki.DrawYukiFeet;
	import org.cubeland.game.core.drawing.yuki.DrawYukiHeadContainer;
	import org.cubeland.game.core.drawing.yuki.DrawYukiShadow;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.view.layer.ViewportLayer;
	import org.papervision3d.view.Viewport3D;

	/**
	 * CubeLand.org Game
	 * @author Duarte Peixinho
	 */
	public class DrawYuki extends DisplayObject3D
	{
		private var _head:DrawYukiHeadContainer;
		private var _feet:DrawYukiFeet;
		private var _shadow:DrawYukiShadow;
		private var _stopped:Boolean = false;
		public function DrawYuki(viewport:Viewport3D)
		{
			
			_head = new DrawYukiHeadContainer();
			_feet = new DrawYukiFeet();
			_shadow = new DrawYukiShadow();
			_shadow.y -= 90;
			_feet.y -= 70;		
			_feet.z-=20;	
			
			var vpHead:ViewportLayer = viewport.getChildLayer(_head, true);
			var vpFeet:ViewportLayer = viewport.getChildLayer(_feet, true);			
			var vpShadow:ViewportLayer = viewport.getChildLayer(_shadow, true);
			vpHead.layerIndex = 3;
			vpFeet.layerIndex = 2;
			vpShadow.layerIndex = 1;
			
			addChild(_shadow);
			addChild(_head);
			addChild(_feet);
			
		}
		public function walk():void {
			_feet.walk();
			_head.walk();
			_stopped=false;
		}

		public function stop():void {
			_feet.stop();
			_head.stop();
			_stopped=true;	
		}
		
		public function update():void {
			_feet.updateFeetPos();
			if (_stopped) stop();
		}

		public function lookLeft() : void {
			_head.lookLeft();
		}
		public function lookRight() : void {
			_head.lookRight();
		}
		public function lookCenter() : void {
			_head.lookCenter();
		}
		public function lookUp() : void {
			_head.lookUp();
		}
		public function lookDown() : void {
			_head.lookDown();
		}
		
	}
}